package com.koron.standard.config;

import org.koron.ebs.mybatis.ADOSessionImpl;
import org.koron.ebs.mybatis.SessionFactory;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

import javax.sql.DataSource;

/**
 * @author jzp
 * @since 2021/7/13 10:13
 */
@Configuration
public class DataSourceConfig {

    @Bean
    @Primary
    @ConfigurationProperties(prefix="spring.datasource")
    public DataSource primaryDataSource() {
        DataSource ds =  DataSourceBuilder.create().build();
        ADOSessionImpl session = new ADOSessionImpl();
        //开启/关闭-自动转换驼峰标识
        SessionFactory.setMapUnderscoreToCamelCase(true);
        session.registeDataSourceMap("_default", ds);
        return ds;
    }

}
